package com.admin.controller;

import com.excel.ExcelUtil;
import com.excel.TerminalInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA
 *
 * @Author yuanhaoyue swithaoy@gmail.com
 * @Description
 * @Date 2018-06-05
 * @Time 16:56
 */
@RestController
public class ExcelController {


    /**
     * 导出 Excel（一个 sheet）
     */
//    @RequestMapping(value = "writeExcel", method = RequestMethod.GET)
//    public void writeExcel(HttpServletResponse response) throws IOException {
//        List<TerminalInfo> list = getList();
//        String fileName = "一个 Excel 文件";
//        String sheetName = "第一个 sheet";
//
//        ExcelUtil.writeExcel(response, list, fileName, sheetName, new TerminalInfo());
//    }

    /**
     * 导出 Excel（多个 sheet）
     */
//    @RequestMapping(value = "writeExcelWithSheets", method = RequestMethod.GET)
//    public void writeExcelWithSheets(HttpServletResponse response) throws IOException {
//        List<ExportInfo> list = getList();
//        String fileName = "一个 Excel 文件";
//        String sheetName1 = "第一个 sheet";
//        String sheetName2 = "第二个 sheet";
//        String sheetName3 = "第三个 sheet";
//
//        ExcelUtil.writeExcelWithSheets(response, list, fileName, sheetName1, new ExportInfo())
//                .write(list, sheetName2, new ExportInfo())
//                .write(list, sheetName3, new ExportInfo())
//                .finish();
//    }

//    private List<TerminalInfo> getList() {
//
//
//        return list;
//    }
}